home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 10.2 KB | 320 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPullDM.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPULLDM_H
- #define FWPULLDM_H
-
- #ifndef FWMNUITM_H
- #include "FWMnuItm.h"
- #endif
-
- #ifndef FWRESACC_H
- #include "FWResAcc.h"
- #endif
-
- // ----- ODUtil Includes -----
-
- #ifndef FWORDCOL_H
- #include "FWOrdCol.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMenuBar;
- class FW_CLASS_ATTR FW_CPrivOrderedCollection;
- class FW_CLASS_ATTR ODPart;
- class FW_CLASS_ATTR ODMenuBar;
-
- //========================================================================================
- // class FW_CPullDownMenu
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPullDownMenu
- {
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- FW_CPullDownMenu(Environment* ev);
-
- FW_CPullDownMenu(Environment* ev,
- const FW_CString& menuTitle);
-
- FW_CPullDownMenu(Environment* ev,
- FW_CResourceFile &resFile,
- FW_ResourceId resourceId,
- unsigned long stringId);
-
- FW_CPullDownMenu(Environment* ev,
- FW_CReadableStream& archive);
-
- virtual ~FW_CPullDownMenu();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //----- Getters/setters -----
- ODMenuID GetMenuID(Environment* ev) const;
- const ODPlatformMenu& GetPlatformMenu(Environment* ev) const;
-
- FW_Boolean IsAttachedToMenuBar(Environment* ev) const;
- FW_CMenuBar* GetMenuBar(Environment* ev) const;
-
- void DisableAll(Environment* ev);
- void EnableAll(Environment* ev);
-
- unsigned long CountItems(Environment* ev) const;
-
- ODCommandID GetCommandID(Environment* ev, short position) const; // position : one-based
-
- //----- Adding items -----
- void AppendTextItem(Environment* ev,
- const FW_CString& text,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void AppendTextItem(Environment* ev,
- FW_CResourceFile &resFile,
- FW_ResourceId resourceId,
- unsigned long id,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertTextItem(Environment* ev,
- const FW_CString& text,
- ODCommandID commandID,
- short afterItem,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertTextItem(Environment* ev,
- FW_CResourceFile &resFile,
- FW_ResourceId resourceId,
- unsigned long id,
- ODCommandID commandID,
- short afterItem,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertTextItemAfterCommand(Environment* ev,
- const FW_CString& text,
- ODCommandID commandID,
- ODCommandID afterCommand,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertTextItemAfterCommand(Environment* ev,
- FW_CResourceFile &resFile,
- FW_ResourceId resourceId,
- unsigned long id,
- ODCommandID commandID,
- ODCommandID afterCommand,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void AppendToggleItem(Environment* ev,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void AppendToggleItem(Environment* ev,
- FW_CResourceFile &resFile,
- FW_ResourceId resourceId,
- unsigned long trueId,
- unsigned long falseId,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertToggleItem(Environment* ev,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- short afterItem,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertToggleItem(Environment* ev,
- FW_CResourceFile &resFile,
- FW_ResourceId resourceId,
- unsigned long trueId,
- unsigned long falseId,
- ODCommandID commandID,
- short afterItem,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertToggleItemAfterCommand(Environment* ev,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- ODCommandID afterCommand,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void InsertToggleItemAfterCommand(Environment* ev,
- FW_CResourceFile &resFile,
- FW_ResourceId resourceId,
- unsigned long trueId,
- unsigned long falseId,
- ODCommandID commandID,
- ODCommandID afterCommand,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
-
- void AppendSubMenu(Environment* ev,
- FW_CPullDownMenu* adoptSubMenu);
-
- void InsertSubMenu(Environment* ev,
- FW_CPullDownMenu* adoptSubMenu,
- short afterItem);
-
- void InsertSubMenuAfterCommand(Environment* ev,
- FW_CPullDownMenu* adoptSubMenu,
- ODCommandID afterCommand);
-
- void AppendSeparator(Environment* ev);
-
- void InsertSeparator(Environment* ev,
- short afterItem);
-
- void InsertSeparatorAfterCommand(Environment* ev,
- ODCommandID afterCommand);
-
- //----- Removing items -----
- void RemoveItem(Environment* ev,
- short position);
-
- //----- Archiving -----
- static void* Read(FW_CReadableStream& archive);
- static void Write(FW_CWritableStream& archive, const void* thePullDownMenu);
- void Flatten(Environment* ev, FW_CWritableStream& archive) const;
-
- // ----- Parent Menu Item
- FW_CMenuItem* GetParentMenuItem(Environment* ev) const;
- void SetParentMenuItem(Environment* ev,
- FW_CMenuItem* menuItem);
-
- // ----- Adopt Items
- void AdoptMenuItemLast(Environment* ev,
- FW_CMenuItem* menuItem);
- void AdoptMenuItemAfter(Environment* ev,
- FW_CMenuItem* menuItem,
- short afterItem);
-
-
- //----------------------------------------------------------------------------------------
- // Internal use only
- //
- public:
- void PrivInitialize(Environment* ev, const FW_CString& menuTitle);
-
- FW_CPullDownMenu* PrivFindMenuWithID(Environment* ev, ODMenuID menuID) const;
-
-
- FW_CMenuItem* PrivGetMenuItem(Environment* ev, ODCommandID commandID) const;
-
- void PrivAttachedToMenuBar(Environment* ev,
- FW_CMenuBar* menuBar,
- ODMenuID beforeID);
- void PrivDetachedFromMenuBar(Environment* ev,
- FW_CMenuBar* menuBar);
-
- void PrivAttach(Environment* ev,
- FW_CMenuBar* menuBar);
- void PrivDetach(Environment* ev,
- FW_CMenuBar* menuBar);
-
- short PrivAcquireMenuID(Environment* ev,
- FW_CMenuBar* menuBar);
- void PrivRelinquishMenuID(Environment* ev);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- ODMenuID fMenuID; // if -1 the menu is not attached
- ODPlatformMenu fPlatformMenu;
- FW_CMenuBar* fMenuBar; // if NULL the menu is not attached
- FW_CPrivOrderedCollection* fItems;
- FW_CMenuItem* fParentMenuItem; // NULL if not a submenu
- };
-
- //----- Archiving -----
- FW_FUNC_ATTR FW_CReadableStream& operator>>(FW_CReadableStream& archive, FW_CPullDownMenu*& object);
- FW_FUNC_ATTR FW_CWritableStream& operator<<(FW_CWritableStream& archive, const FW_CPullDownMenu* object);
-
- //========================================================================================
- // FW_CPullDownMenu inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetMenuID
- //----------------------------------------------------------------------------------------
- inline ODMenuID FW_CPullDownMenu::GetMenuID(Environment* ev) const
- {
- return fMenuID;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetPlatformMenu
- //----------------------------------------------------------------------------------------
- inline const ODPlatformMenu& FW_CPullDownMenu::GetPlatformMenu(Environment* ev) const
- {
- return fPlatformMenu;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::IsAttachedToMenuBar
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CPullDownMenu::IsAttachedToMenuBar(Environment* ev) const
- {
- return fMenuBar != NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetMenuBar
- //----------------------------------------------------------------------------------------
- inline FW_CMenuBar* FW_CPullDownMenu::GetMenuBar(Environment* ev) const
- {
- return fMenuBar;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::GetParentMenuItem
- //----------------------------------------------------------------------------------------
- inline FW_CMenuItem* FW_CPullDownMenu::GetParentMenuItem(Environment* ev) const
- {
- return fParentMenuItem;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::SetParentMenuItem
- //----------------------------------------------------------------------------------------
- inline void FW_CPullDownMenu::SetParentMenuItem(Environment* ev, FW_CMenuItem* menuItem)
- {
- fParentMenuItem = menuItem;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPullDownMenu::CountItems
- //----------------------------------------------------------------------------------------
- inline unsigned long FW_CPullDownMenu::CountItems(Environment* ev) const
- {
- return fItems->Count();
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-